package reflect;

/**
 * JDK5之后Java提供了一个特性，变长参数
 */
public class ArgsDemo {
    public static void main(String[] args) {
        /*
            变长参数只能是方法的最后一个参数！
            变长参数是编译器认可的，最终编译后会被改为数组

            doSome(1,new String[]{});
            doSome(1,new String[]{"one"});
            doSome(1,new String[]{"one","two"});
            doSome(1,new String[]{"one","two","three"});
            doSome(1,new String[]{"one","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three"});
         */
        doSome(1);
        doSome(1,"one");
        doSome(1,"one","two");
        doSome(1,"one","two","three");
        doSome(1,"one","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three","two","three");
    }

    //public static void doSome(int a,String[] arg){
    public static void doSome(int a,String... arg){

        System.out.println(arg.length);
    }

}



